package org.moonshiner.controller.service.impl;

import org.springframework.transaction.annotation.Transactional;

import org.moonshiner.controller.dao.hibernate.GenericDao;

public class GenericService<T extends GenericDao<E>, E> {

	protected T dao;

	public T getDao() {
		return dao;
	}

	@Transactional
	public E save(E entity) {
		return dao.save(entity);
	}

	@Transactional
	public E update(E entity) {
		return dao.update(entity);
	}

	@Transactional
	public void delete(E entity) {
		dao.delete(entity);
	}

	@Transactional
	public void delete(Integer id) {
		dao.delete(id);
	}

	@Transactional
	public E get(Integer id) {
		return dao.get(id);
	}

	public void setDao(T dao) {
		this.dao = dao;
	}

	public GenericService(T dao) {
		this.dao = dao;
	}

}
